package kr.or.smardi.smardi_AScan.Device;

import java.util.*;

import android.util.*;

public class LookupTable {

	private String Model = null;
	private ArrayList<dataSet> lookupTable = null;

	public LookupTable(String model) {
		Model = model;
	}

	public ArrayList<dataSet> getLookupTable() {
		lookupTable = new ArrayList<dataSet>();
		
			lookupTable.add(new dataSet(0.00, 0.0));
			lookupTable.add(new dataSet(0.01, 0.01));
			lookupTable.add(new dataSet(0.02, 0.02));
			lookupTable.add(new dataSet(0.03, 0.03));
			lookupTable.add(new dataSet(0.04, 0.04));
			lookupTable.add(new dataSet(0.05, 0.05));
			lookupTable.add(new dataSet(0.06, 0.06));
			lookupTable.add(new dataSet(0.07, 0.07));
			lookupTable.add(new dataSet(0.08, 0.08));
			lookupTable.add(new dataSet(0.09, 0.09));
			lookupTable.add(new dataSet(0.10, 0.10));
			lookupTable.add(new dataSet(0.10, 0.15));
			lookupTable.add(new dataSet(0.20, 0.20));
			lookupTable.add(new dataSet(0.25, 0.25));
			lookupTable.add(new dataSet(0.30, 0.30));
			lookupTable.add(new dataSet(0.30, 0.35));
			lookupTable.add(new dataSet(0.40, 0.40));

		return lookupTable;
	}

	public class dataSet {
		public double x = 0;
		public double y = 0;

		public dataSet() {
			x = 0;
			y = 0;
		}
		
		public dataSet(double x, double y) {
			this.x = x;
			this.y = y;
		}
	}

	public double convertAlcholeToVolume(double alchole) {

		double a = 1;
		double b = 0;
		if (Model.equals("SHV-E160S") 
				|| Model.equals("SHV-E160L")
				|| Model.equals("SHV-E160K")) {
			a = 3346.1;
			b = 17285;
		} else if (Model.equals("maguro") || Model.equals("SHW-M420K")
				|| Model.equals("SHW-M420S")) {
			// 갤럭시 넥서스
			return -1;
		} else if (Model.equals("SHW-M440S") || Model.equals("SHV-E200S")
				|| Model.equals("SHV-E210L")
				|| Model.equals("SHV-E210S")) {
			// 갤스 3일 경우
			a = 3548.1;
			b = 22200;
		} else if (Model.equals("SHV-E110S") || Model.equals("SHW-M250K")
				|| Model.equals("SHW-M250L")) {
			// 갤럭시 S2일 경우
			a = 6701.9;
			b = 39095;
		} else {
			return -1;
		}

		return a * Math.log(alchole) + b;
	}

	public double convertVolumeToAlchole(double volume) {

		double a = 0;
		double b = 0;

		a = 6701.9;
		b = 39095;
		
		if (Model.equals("SHV-E160S") || Model.equals("SHV-E160L")
				|| Model.equals("SHV-E160K")) {
			// 노트
			a = 3346.1;
			b = 17285;
		} else if (Model.equals("maguro") || Model.equals("SHW-M420K")
				|| Model.equals("SHW-M420S")) {
			// 갤럭시 넥서스
		} else if (Model.equals("SHW-M440S") || Model.equals("SHV-E200S")
				|| Model.equals("SHV-E210L")) {
			// 갤스 3일 경우
			a = 3548.1;
			b = 22200;
		} else if (Model.equals("SHV-E110S") || Model.equals("SHW-M250K")
				|| Model.equals("SHW-M250L")
				|| Model.equals("SHW-M250S")) {
			// 갤럭시 S2일 경우
			a = 6701.9;
			b = 39095;
		} else {
			
		}

		return Math.exp((volume - b) / a);
	}
}
